﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using PortalIntranet.DatabaseComponents.Administracao;
using PortalIntranet.DatabaseComponents.Comun;
using System.Data.Entity.ModelConfiguration;

namespace PortalIntranet.DatabaseComponents.WebParts.Galerias
{
	[Serializable]
	[Table("GaleriasItens")]
	public class GaleriaItem : Entidade
	{
		public GaleriaItem()
		{
		}

		[Required, MaxLength(50)]
		public string Nome { get; set; }

		[Required, MaxLength(100)]
		public string Descricao { get; set; }

		[Required, MaxLength(300)]
		public string Url { get; set; }

		[Required, MaxLength(300)]
		public string Thumb { get; set; }

		public int Ordem { get; set; }

		public TipoMedia TipoMedia { get; set; }

		#region Galeria
		public int GaleriaId { get; set; }

		public virtual Galeria Galeria { get; set; }
		#endregion
	}

	internal class GaleriaItemConfiguration : EntityTypeConfiguration<GaleriaItem>
	{
		internal GaleriaItemConfiguration()
		{
			this.HasRequired(b => b.Galeria)
				.WithMany(i => i.Itens)
				.HasForeignKey(b => b.GaleriaId);
		}
	}
}
